<template>
	<view>
		<z-paging ref="paging" v-model="list" @query="getPage" :auto="false">
			<cu-custom slot="top" :bgColor="'bg-' + theme.themeColor" :isBack="true">
				<block slot="content">优惠券</block>
			</cu-custom>
			<view v-for="(item,index) in list">
				<coupon-info :couponInfo="item"></coupon-info>
			</view>
		</z-paging>
	</view>

</template>

<script>
	import {
		getPage as getCouponPage
	} from '@/api/couponinfo.js';
	import couponInfo from '@/components/coupon-info/index.vue';
	export default {
		components: {
			couponInfo
		},
		data() {
			return {
				theme: getApp().globalData.theme,
				list: [],
			};
		},
		onLoad() {
			getApp().initPage().then(res => {
				this.$nextTick(function() {
					this.$refs.paging.reload();
				})
			})
		},
		methods: {
			/**
			 * 分页查询
			 */
			getPage(pageNo, pageSize) {
				getCouponPage({
					current: pageNo,
					size: pageSize,
					descs: 'create_time',
				}).then(res => {
					this.$refs.paging.complete(res.data.records);
				});
			},
		}
	}
</script>

<style>
</style>
